*-------------------------------------------------------------------------------------------------------------
*
*	RETURN VOLATILITIES 
*
*-------------------------------------------------------------------------------------------------------------


set more off

qui{


*_________ GET DATA ____________
use "data/final dataset/JSTdatasetR4.dta", clear

*____ DECLARE TIME SERIES _____
tsset ifs year, yearly
egen ccode = group(iso)


foreach r in eq_tr housing_tr bond_tr bill_rate {	
	//gen l_`r' = ln(`r')
	replace `r' = 100*`r'
	}
foreach r in eq_tr housing_tr bond_tr bill_rate {	
	local det `r'
	include code/detrend_hp.do
	}

//outliers
foreach r in eq_tr_hp housing_tr_hp bond_tr_hp bill_rate_hp {	
	replace `r'=. if `r' >=200
	replace `r'=. if `r' <-100
	}
	
	n sum eq_tr_hp housing_tr_hp bond_tr_hp bill_rate_hp
	n sum eq_tr_hp housing_tr_hp bond_tr_hp bill_rate_hp if  year >=1947

	n sum eq_tr_hp housing_tr_hp bond_tr_hp bill_rate_hp if iso=="USA"
	n sum eq_tr_hp housing_tr_hp bond_tr_hp bill_rate_hp if iso=="USA" & year >=1947
	tsline eq_tr_hp if iso=="USA"
}
